<!DOCTYPE html>
<html lang="en" xmlns:v-on="http://www.w3.org/1999/xhtml" xmlns:v-bind="">
<meta http-equiv="Expires" content="0">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-control" content="no-cache">
<meta http-equiv="Cache" content="no-cache">
<head>
    <meta charset="UTF-8">
    <title>注册用户</title>
    <link href="resources/css/common/bootstrap3.min.css" rel="stylesheet" type="text/css"/>
    <link rel="stylesheet" type="text/css" href="resources/css/common/uploadify.css"/>
    <link rel="stylesheet" href="resources/css/common/bootstrap-select.min.css">
    <link rel="stylesheet" href="resources/css/common/from.css">
</head>
<style>
    #demo {
        margin-top: 20px;
    }

</style>
<baby>
    <div class="container" >
        <div class="page-header navbar-color">
            <h1 id="navbars">注册用户</h1>
        </div>
    <div id="demo">
        <div class="form-horizontal add-border">
            <input type="hidden" v-model="status">
            <div class="form-group">
                <label class="col-sm-3 control-label">真实姓名</label>
                <div class="col-sm-3">
                    <input type="text" v-model="realName" class="form-control" placeholder="请输入真实姓名">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">登陆账号</label>
                <div class="col-sm-3">
                    <input type="text" v-model="nickName" class="form-control" placeholder="请输入昵称">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">密码</label>
                <div class="col-sm-3">
                    <input type="password" v-model="pwd" class="form-control" placeholder="请输入密码">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">确认密码</label>
                <div class="col-sm-3">
                    <input type="password" v-model="confirmPwd" class="form-control" placeholder="请输入确认密码">
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">备注</label>
                <div class="col-sm-3">
                    <input type="text" v-model="description" class="form-control"  placeholder="请输入备注">
                </div>
            </div>

            <div class="form-group">
                <div class="col-sm-offset-3 col-sm-10">
                    <button type="button" class="btn btn-primary" v-on:click="addInfo">提交</button>
                </div>
            </div>
        </div>
    </div>
    </div>
</baby>

<script type="text/javascript" src="resources/js/common/jquery-2.1.1.min.js"></script>
<script src="resources/js/common/bootstrap3.min.js" type="text/javascript"></script>
<script src="resources/js/common/vue.min.js"></script>
<script src="resources/js/common/jquery.uploadify.min.js" type="text/javascript"></script>
<script src="resources/js/common/bootstrap-select.min.js"></script>
<script src="resources/js/common/common.js"></script>
<script>
    var demo = new Vue({
        el: '#demo',
        data: {
            realName: '',
            nickName: '',
            pwd: '',
            confirmPwd: '',
            description:''

        }, methods: {
            addInfo: function () {
                if(this.realName=="")
                {
                    alert("真实姓名不能为空");
                    return ;
                }
                if(this.nickName=="")
                {
                    alert("昵称不能为空");
                    return ;
                }
                if(this.pwd=="")
                {
                    alert("密码不能为空");
                    return ;
                }
                if(this.confirmPwd=="")
                {
                    alert("确认密码不能为空");
                    return ;
                }

                jQuery.ajax({
                    url: '/login/regist',
                    type: "post",
                    data: {realName:this.realName,nickName:this.nickName,pwd:this.pwd,confirmPwd:this.confirmPwd,description:this.description},
                    async: false,
                    dataType: "json",
                    success: function (data) {
                        if(data.retCode==1) {
                            alert("注册成功");
                            window.location.href="/html/operator/operator.html";
                        }
                        else
                        {
                            var errorMsg=data.retMsg;
                            if(data.retCode==-2)
                            {
                                errorMsg="用户已经存在";
                            }
                            if(data.retCode==-3)
                            {
                                errorMsg="两次密码不相符"
                            }
                            alert("注册失败:"+errorMsg);
                            return ;
                        }

                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown, XMLHttpResponse) {
                        alert('程序有误')
                    }
                });
                return ;
            },
            getTrans: function (id) {

            },
            allCategory: function () {
                var t = this;
            }
        },
        mounted: function () {
        },
    });

</script>
</html>

